package com.ms3ds.deviceData.service.impl;

import java.util.List;
import com.ms3ds.common.core.utils.DateUtils;
import com.ms3ds.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ms3ds.deviceData.mapper.CameraMapper;
import com.ms3ds.deviceData.domain.Camera;
import com.ms3ds.deviceData.service.ICameraService;

/**
 * 视频设备Service业务层处理
 * 
 * @author zlw
 * @date 2025-09-20
 */
@Service
public class CameraServiceImpl implements ICameraService 
{
    @Autowired
    private CameraMapper cameraMapper;

    /**
     * 查询视频设备
     * 
     * @param id 视频设备主键
     * @return 视频设备
     */
    @Override
    public Camera selectCameraById(Long id)
    {
        return cameraMapper.selectCameraById(id);
    }

    /**
     * 查询视频设备列表
     * 
     * @param camera 视频设备
     * @return 视频设备
     */
    @Override
    public List<Camera> selectCameraList(Camera camera)
    {
        return cameraMapper.selectCameraList(camera);
    }

    /**
     * 新增视频设备
     * 
     * @param camera 视频设备
     * @return 结果
     */
    @Override
    public int insertCamera(Camera camera)
    {
        Long userId = SecurityUtils.getUserId();
        camera.setCreateBy(String.valueOf(userId));
        camera.setCreateTime(DateUtils.getNowDate());
        return cameraMapper.insertCamera(camera);
    }

    /**
     * 修改视频设备
     * 
     * @param camera 视频设备
     * @return 结果
     */
    @Override
    public int updateCamera(Camera camera)
    {
        Long userId = SecurityUtils.getUserId();
        camera.setUpdateBy(String.valueOf(userId));
        camera.setUpdateTime(DateUtils.getNowDate());
        return cameraMapper.updateCamera(camera);
    }

    /**
     * 批量删除视频设备
     * 
     * @param ids 需要删除的视频设备主键
     * @return 结果
     */
    @Override
    public int deleteCameraByIds(Long[] ids)
    {
        return cameraMapper.deleteCameraByIds(ids);
    }

    /**
     * 删除视频设备信息
     * 
     * @param id 视频设备主键
     * @return 结果
     */
    @Override
    public int deleteCameraById(Long id)
    {
        return cameraMapper.deleteCameraById(id);
    }
}
